<%@page import="java.util.Vector"%>
<%@page import="it.crosato.stage.shared.objects.EntityDefinition"%>
<html>

<head>
	<title>CoMeta - Dettagli del confronto</title>
	<link type="text/css" rel="stylesheet" href="css/web.css" media="screen" />
</head>

<body>

	<div class="app">

	<div class="title">
		<h1>CoMeta</h1>
	</div>
	
	<div class="content">
	
		<div class="side">
			<form action="selection.html" method="get">
				<%long time = Long.class.cast(session.getAttribute("time")); %>
				<input type="hidden" name="time" value="<%out.print(time);%>">
				<input type="image" src="pics/freccia-sx.png">
			</form>
		</div>
		
		<div class=result>
			<div class="navigation">
				<ul>
				    <li><a href="pathways.html">Vie metaboliche</a></li>
				    <li><a href="sets.html">Insiemi</a></li>
					<li><a href="invariants.html">Reti di Petri</a></li>
				    <li id="activelink"><a href="mapping.html">Matrici distanza</a></li>
				    <li><a href="tree.html">Albero filogenetico</a></li>
				</ul>
			</div>
			<div class="resultBox">
				<%
					@SuppressWarnings("unchecked")
					Vector<EntityDefinition> organisms = (Vector<EntityDefinition>)session.getAttribute("selectedOrganisms");
					@SuppressWarnings("unchecked")
					Vector<EntityDefinition> pathways = (Vector<EntityDefinition>)session.getAttribute("selectedPathways");
					double[][] setDistanceMatrix = double[][].class.cast(session.getAttribute("setDM"));
					double[][] invDistanceMatrix = double[][].class.cast(session.getAttribute("invDM"));
					double[][] distanceMatrix = double[][].class.cast(session.getAttribute("totDM")); %>
					<h3>Matrice delle distanze basata sugli insiemi</h3>
					<table class="distanceMatrix">
						<tr><th id="tableCorner"></th>
					<% 
						for (int i = 0; i < organisms.size(); i++) {
							out.println("<th>" + organisms.get(i).getDescription() + "</th>");
						}
						out.println("</tr>");
						for (int i = 0; i < setDistanceMatrix.length; i++) {
							out.println("<tr>");
							out.println("<th>" + organisms.get(i).getDescription() + "</th>");
							for (int j = 0; j < setDistanceMatrix[0].length; j++) {
								out.println("<td>" + setDistanceMatrix[i][j] + "</td>");
							}
							out.println("</tr>");
						}
					%>
					</table>
					<h3>Matrice delle distanze basata sulle reti di Petri</h3>
					<table class="distanceMatrix">
						<tr><th id="tableCorner"></th>
					<% 
						for (int i = 0; i < organisms.size(); i++) {
							out.println("<th>" + organisms.get(i).getDescription() + "</th>");
						}
						out.println("</tr>");
						for (int i = 0; i < invDistanceMatrix.length; i++) {
							out.println("<tr>");
							out.println("<th>" + organisms.get(i).getDescription() + "</th>");
							for (int j = 0; j < invDistanceMatrix[0].length; j++) {
								out.println("<td>" + invDistanceMatrix[i][j] + "</td>");
							}
							out.println("</tr>");
						}
					%>
					</table>
					<h3>Matrice delle distanze totale</h3>
					<table class="distanceMatrix">
						<tr><th id="tableCorner"></th>
					<% 
						for (int i = 0; i < organisms.size(); i++) {
							out.println("<th>" + organisms.get(i).getDescription() + "</th>");
						}
						out.println("</tr>");
						for (int i = 0; i < distanceMatrix.length; i++) {
							out.println("<tr>");
							out.println("<th>" + organisms.get(i).getDescription() + "</th>");
							for (int j = 0; j < distanceMatrix[0].length; j++) {
								out.println("<td>" + distanceMatrix[i][j] + "</td>");
							}
							out.println("</tr>");
						}
					%>
					</table>
			</div>
		</div>
	</div>
	
	<div class="footer">
		<span>Strumento per la comparazione di reti metaboliche</span>
	</div>
	
	</div>

</body>

</html>